<template>
	<view style="margin: 20px;">
		<scroll-view scroll-y="true" class="tack-list" @scrolltolower="touchLower" @scrolltoupper="touchUpper">
			<view class="tack-item" v-for="(item,index) in tableList" :key="index">
				<view class="tack-item-content">
					<view class="tack_item_tittle">磅单号：{{item.poundsNo}}</view>
					<view style="margin-top: 15rpx;">车牌号：{{item.carNo}}</view>
					<view>摄像头：{{item.webcamId}}</view>
					<view>是否合格：{{item.valid==0?'不合格': '合格'}}</view>
					<view>层级：{{item.tier}}</view>
				</view>
				<image mode="widthFix" v-if="item.imgUrl" :src="item.imgUrl" class="tack-image" />
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import receiptList from "../../common/ReceiptList.js"
	export default {
		data() {
			return {
				tableList: [],
				page: {
					total: 0,
					pageSize: 8,
					pageIndex: 1
				},
				poundsNo: null
			}
		},
		onLoad(option){
			this.poundsNo = option.poundsNo;
			console.log(this.poundsNo)
		},
		onShow(){
			this.touchUpper();
		},
		methods: {
			touchUpper(){
				this.page.pageIndex =1;
				this.tableList = [];
				this.getPhotoList();
			},
			touchLower(){
				if(this.page.pageIndex < this.page.total){
					this.page.pageIndex++;
					this.getPhotoList();
				}
			},
			getPhotoList(){
				let param = {pageNum: this.page.pageIndex, pageSize: this.page.pageSize, poundsNo: this.poundsNo};
				console.log(param)
				receiptList.getPhotoList(param).then(
					res => {
						console.log(res)
						if (null != res && res.code ==0 && null != res.data) {
							res.data.records.forEach(item=>{
								if(item.imgUrl){
									item.imgUrl = item.imgUrl.replace(/^(\\\\)$/g,'/');
								}
							});
							this.tableList.push(...res.data.records);
							this.page.total = res.data.pages;
						}
					}).catch(customerEx => {
					console.log(customerEx);
				});
			}
		}
	}
</script>

<style>
	/*列表样式*/
	.tack-list {
		width: 100%;
		height: calc(100vh);
	}

	.tack-item {
		margin: 15px 0;
		border: 1px solid #acacac;
		border-radius: 5px;
		display: flex;
		justify-content: space-around;
		padding: 10px;
	}

	.tack-item-content {
		color: #acacac;
		line-height: 48rpx;
		width: 100%;
		margin-right: 0;
	}

	.tack_item_tittle {
		font-size: 35rpx;
		color: #0076CA;
	}

	.tack-image {
		width: 38%;
	}
</style>
